import ContactCenter from "./components/ContactCenter";
import { Button, Divider, Flex } from "antd";
import { useState } from "react";

let sipCall: any = null;

function App() {
  const [sipCallInfo, setSipCallInfo] = useState<any>(null);

  // 拨打电话
  function handleCall() {
    sipCall.call("8888");
  }

  return (
    <>
      <Divider orientation="center" plain>
        当前注册信息：sip地址-{sipCallInfo?.sipUrl}；本地号码-{sipCallInfo?.localAgent}
      </Divider>
      <Flex justify={"center"} className={"mt-20"}>
        <Button onClick={handleCall}>拨打电话（8888）</Button>
      </Flex>

      <ContactCenter options={{
        // host: '121.43.120.176',
        host: "192.168.2.11",
        port: "5066",
        proto: false,
        extNo: "8889",
        extPwd: "8889"
      }} onRegister={(sip) => {
        setSipCallInfo(JSON.parse(JSON.stringify({
          sipUrl: sip.socket._sip_uri,
          localAgent: sip.localAgent
        })));
        sipCall = sip;
      }}></ContactCenter>
    </>

  );
}

export default App;


